
def Shared_password_button():
    text = "The password should contain: \n"
    text = text + "1) minimum 10 characters\n"
    text = text + "2) maximum 254 characters\n"
    text = text + "3) one number 0123456789\n"
    text = text + "4) one special character !@#$%^&*()-_+=[]{}<>?/|\\`~;:\n"
    text = text + "5) one lower case letter abcdefghijklmnopqrstuvwxyz\n"
    text = text + "6) one upper case letter ABCDEFGHIJKLMNOPQRSTUVWXYZ\n"
    open_text_popup(text)


def rename_shared_encoding_configuration_button ( ):

    global xrn_main_window_global
    slayout_local = xrn_main_window_global.jlayout_str

    display = get_from_layout ( slayout_local, "rename_shared_encoding_configuration" )["fields"][2]["display"]
    selection = get_from_layout ( slayout_local, "Shared_encoding_parameter_selection_id" )["fields"][2]["selection"] 

    obj = get_from_layout ( slayout_local, "encoding_parameter_names_id" )
    obj["fields"][2]["items"][int(selection)]["data"] = display
    slayout_local = set_to_layout( slayout_local, obj )

    render_layout(  slayout_local )
    return 0


def generate_encoding_configuration( initial_layout ):

    initial_layout.append({ "type": "rows", "display": "encoding configurations", "id": "encoding_configurations_panel_id", "expand": "off", "rows": [] })

    initial_layout[-1]["rows"].append({ 
                 "permission": "read_write",
                 "id": "Shared_encoding_parameter_selection_id",
                 "type": "row",
                 "fields": [
                     {
                         "type": "textbox",
                         "display": "Shared encoding param selection"
                     },
                     {
                         "type": "void"
                     },
                     {
                         "type": "combobox",
                         "selection": "0",
                         "button": "off",   
                         "checkbox": "off",
                         "function": "",
                         "items": [
                             {
                                 "display": "0"
                             },
                             {
                                 "display": "1"
                             },
                             {
                                 "display": "2"
                             },
                             {
                                 "display": "3"
                             },
                             {
                                 "display": "4"
                             },
                             {
                                 "display": "5"
                             },
                             {
                                 "display": "6"
                             },
                             {
                                 "display": "7"
                             },
                             {
                                 "display": "8"
                             },
                             {
                                 "display": "9"
                             },
                             {
                                 "display": "10"
                             },
                             {
                                 "display": "11"
                             },
                             {
                                 "display": "12"
                             },
                             {
                                 "display": "13"
                             },
                             {
                                 "display": "14"
                             },
                             {
                                 "display": "15"
                             },
                             {
                                 "display": "16"
                             }
                          ] 
                     } 
                  ]
                })


    initial_layout[-1]["rows"].append({ 
                                         "permission": "read_write",
                                         "id": "rename_shared_encoding_configuration",
                                         "type": "row",
                                         "fields": [
                                             {
                                                 "type": "textbox",
                                                 "display": "rename shared encoding conf"
                                             },
                                             {
                                                 "type": "void"
                                             },
                                             {
                                                 "type": "string",
                                                 "button_display": "rename",
                                                 "display": "",
                                                 "visibility": "open",
                                                 "button": "on",
                                                 "thread": "off",
                                                 "checkbox": "off",
                                                 "function": "rename_shared_encoding_configuration_button"
                                             }
                                         ]
                                     })

    initial_layout[-1]["rows"].append({ 
            "permission": "read_write",
            "id": "encoding_parameter_names_id",
            "type": "row",
            "fields": [
                {
                    "type": "textbox",
                    "display": "encoding param names"
                },
                {
                    "type": "void"
                },
                {
                    "type": "archive",
                    "selection": "encoding param 0",
                    "items": [
                        {
                            "display": "encoding param 0",
                            "data": "encoding param 0"
                        },
                        {
                            "display": "encoding param 1",
                            "data": "encoding param 1"
                        },
                        {
                            "display": "encoding param 2",
                            "data": "encoding param 2"
                        },
                        {
                            "display": "encoding param 3",
                            "data": "encoding param 3"
                        },
                        {
                            "display": "encoding param 4",
                            "data": "encoding param 4"
                        },
                        {
                            "display": "encoding param 5",
                            "data": "encoding param 5"
                        },
                        {
                            "display": "encoding param 6",
                            "data": "encoding param 6"
                        },
                        {
                            "display": "encoding param 7",
                            "data": "encoding param 7"
                        },
                        {
                            "display": "encoding param 8",
                            "data": "encoding param 8"
                        },
                        {
                            "display": "encoding param 9",
                            "data": "encoding param 9"
                        },
                        {
                            "display": "encoding param 10",
                            "data": "encoding param 10"
                        },
                        {
                            "display": "encoding param 11",
                            "data": "encoding param 11"
                        },
                        {
                            "display": "encoding param 12",
                            "data": "encoding param 12"
                        },
                        {
                            "display": "encoding param 13",
                            "data": "encoding param 13"
                        },
                        {
                            "display": "encoding param 14",
                            "data": "encoding param 14"
                        },
                        {
                            "display": "encoding param 15",
                            "data": "encoding param 15"
                        },
                        {
                            "display": "encoding param 16",
                            "data": "encoding param 16"
                        }
                    ]
                }
            ]
        })

    offset = 3
    for i in range(0,17) :
    
        initial_layout[-1]["rows"].append({
                                                      "permission": "read_write",
                                                      "id": "combobox_en_shared_enc_conf_" + str(i),
                                                      "type": "row",
                                                      "fields": [  
                                                          {
                                                              "type": "textbox",
                                                              "display": "enable param " + str(i)
                                                          },
                                                          {
                                                              "type": "void"
                                                          },
                                                          {
                                                              "type": "combobox",
                                                              "selection": "disable",
                                                              "button": "off",
                                                              "checkbox": "off",
                                                              "function": "",
                                                              "items": [
                                                                  {
                                                                      "display": "enable"
                                                                  },
                                                                  {
                                                                      "display": "disable"
                                                                  }
                                                              ] 
                                                          } 
                                                      ] 
                                                    })
        initial_layout[-1]["rows"].append({
                                                      "permission": "read_write",
                                                      "id": "Shared_encoding_parameters_" + str(i),
                                                      "type": "row",
                                                      "fields": [
                                                          {
                                                              "type": "textbox",
                                                              "display": "encoding param " + str(i)
                                                          },
                                                          {
                                                              "type": "void"
                                                          },
                                                          {
                                                              "type": "path",
                                                              "display": "",
                                                              "target": "file",
                                                              "direction": "input"
                                                          }
                                                      ]
                                                    })
    return initial_layout 
